# 可以定义统一的响应类（可选）
from flask import jsonify
from .BaseResponse import BaseResponse


class ApiResponse:
    @classmethod
    def success(cls, message="操作成功", data=None):
        return jsonify({
            "code": 0,
            "message": message,
            "data": data
        }), 200

    @classmethod
    def error(cls, code=1, message="操作失败", data=None):
        return jsonify({
            "code": code,
            "message": message,
            "data": data
        }), 200

    @classmethod
    def error_from_baseResponse(cls, baseResponse: BaseResponse, data=None):
        return jsonify({
            "code": baseResponse.code,
            "message": baseResponse.message,
            "data": data
        }), 200
